<!--#include file="functions.asp" -->
<%  
	'set cn=Server.CreateObject("ADODB.Connection")
    'cn.Open "MP2ENTTEST2", "MP2", "MP2"
    dim sql , MyBody
	 sRecipients = GetLoginName(request("Loc"))
	
	  sql = "SELECT EMPCODE, LOGINNAME, DEPARTMENT FROM EXIAUTHORITY WHERE EMPCODE='"& request("Loc") & "'"
	  set rs=cn.execute(sql)
	  if rs.eof then
        bManagerID = ""
        bManager = "N"
	  else
	    bManagerID = rs("EMPCODE")
	    bManager = "Y"
	  end if
 	  set rs=nothing
	  
    if (left(request("seqnum"),3)="LVO") then
	sDomainName = "@Premier-oil.com"
	EmailSubject = "Electronic Invoice Approval Notification "  
	EmailBody = "<HTML><HEAD><TITLE></TITLE></HEAD><BODY>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Dear "& request("LocName") &", </font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>You have Low Value Order invoice waiting for your review: </font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Vendor Name: " & request("VendorName") & "</font><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Invoice No: " & request("InvoiceNo") & "</font><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2><b><a href='" & theURL & "/My_InvoiceLVO.asp?LVOnum=" &  request("seqnum")  & "'>Click here for Invoice detail</a></b></font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Thank you for your kind cooperation </font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2><b>Finance Department </b></font>"
	EmailBody = EmailBody & "</BODY></HTML>"
	
	MyBody =  ReformatText(EmailBody)
	SendCDOEmail sRecipients, "", "", "Finance_Department", EmailSubject, MyBody
	
	response.redirect "InvList_LVO.asp" 
	else
	sql = "INSERT INTO EXIHIST (SEQNUM,TRANSTYPE,LOCATION,DEPARTMENT,UPDATEUSER,UPDATESTAMP)"
   	sql = sql & " VALUES ("
   	sql = sql & request("seqnum") & ",'"
   	sql = sql & "SNF','"
    sql = sql & request("Loc") & "','"
   	sql = sql & Dept & "','"
   	sql = sql & usrName & "',"
   	sql = sql & "GETDATE() )"
   	cn.execute(sql)

   
	
    sDomainName = "@Premier-oil.com"
	EmailSubject = "Electronic Invoice Approval Notification "  
	EmailBody = "<HTML><HEAD><TITLE></TITLE></HEAD><BODY>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Dear "& request("LocName") &", </font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>You have invoice waiting for your review: </font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Vendor Name: " & request("VendorName") & "</font><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2>Invoice No: " & request("InvoiceNo") & "</font><BR>"
	if( bManager = "Y") then 
	EmailBody = EmailBody & "<FONT face=Arial size=2><b><a href='" & theURL & "/My_InvApproval_mgr.asp?seqnum=" &  request("seqnum")  & "'>Click here for Invoice detail</a></b></font><BR><BR>"
	else
	EmailBody = EmailBody & "<FONT face=Arial size=2><b><a href='" & theURL & "/My_InvApproval.asp?seqnum=" &  request("seqnum")  & "'>Click here for Invoice detail</a></b></font><BR><BR>"
	end if
	EmailBody = EmailBody & "<FONT face=Arial size=2>Thank you for your kind cooperation </font><BR><BR>"
	EmailBody = EmailBody & "<FONT face=Arial size=2><b>Finance Department </b></font>"
	EmailBody = EmailBody & "</BODY></HTML>"
	
	MyBody = ReformatText(EmailBody)
	SendCDOEmail sRecipients, "", "", "Finance_Department", EmailSubject, MyBody
	
   if (request("isUC")="Y") then
    response.redirect "My_InvApproval.asp?seqnum=" & request("seqnum")
   else
   response.redirect "Outstanding_det.asp?seqnum=" & request("seqnum")
   end if
   end if	
%>
